<!-- Gallery -->
<?php $javascript->link('jquery-1.3.2.min', false); ?>
<?php $javascript->link('slimbox2', false); ?>
<?php echo $html->css('slimbox2',false);  ?>
<!-- End Gallery -->
<?php 
//CT8gU9ak4cy8
	//echo "<fieldset><legend>Location</legend>";
	echo "Title: ".$post['Post']['title']."<br>";
	echo "Address: ".$post['Post']['address']."<br>";
	echo "Description: ".$post['Post']['description']."<br>";
	
				if(isset($post['Image'][0]['Thumbnail']["path_big"]))
					echo $html->link($html->image($post['Image'][0]['Thumbnail']["path_big"]),"../img/".$post['Image'][0]['path'],array("rel"=>"lightbox", 'title'=>$post['Post']["title"]."<br>".$post['Post']["description"],'escape'=>false));
				else 
					echo $html->image("no_image.gif", array('width'=>200, 'height'=>200));
			
	echo "<br>";
	//echo "</fieldset>";
	echo "<fieldset><legend>Information</legend>";
	echo "Title: ".$post['Post']['title']."<br>";
	echo "Address: ".$post['Post']['address']."<br>";
	echo "Description: ".$post['Post']['description']."<br>";
	echo "</fieldset>";
	//Different kind of ways to connect to Yelp (by geopoint, address or mapbounding) 
	$constYelpURL = $yelp->constructGeoPoint("bb7U2kUGpJT6uKBwwHzDPg",$post['Post']['title'],10,$post['Point']['latitude'],$post['Point']['longitude'],2);
	//$constYelpURL = $yelp->constructAddress("bb7U2kUGpJT6uKBwwHzDPg",$post['Post']['title'],20,$post['Post']['address'],"US",2);
	//$constYelpURL = $yelp->constructMapBounding("bb7U2kUGpJT6uKBwwHzDPg",$post['Post']['title'],20,$post['Post']['address'],"US",2);
	if($constYelpURL == 404)
	{
		echo "Could not connect to YELP: Sorry for the inconveniences <br/>";
	}
	else
	{
		//Create object with Yelp results, and check for errors: If no errors, return object (otherwise throw error).
		$YelpObject = $yelp->init($constYelpURL);
		if($YelpObject == NULL || count($YelpObject->businesses) == 0)
		{
			echo "Oooopss!  We could not find information from Yelp for this specific location <br/>";
		}
		else
		{
			//If code==0, everything went ok, we throw the information
			if($YelpObject->message->code  == 0)
			{
				//We get the first business of all the business, or do NearestNeighbor
				$businessRight = $yelp->returnNearest($YelpObject->businesses,$post['Point']['latitude'],$post['Point']['longitude']);
				
				//The results from Yelp are not the ones that the pots was related to (Euclidean Distance too big)
				if ($businessRight == NULL)
				{
					echo "Oooopss!  We could not find information from Yelp for this specific location <br/>";
				}
				else
				{				
					echo "<fieldset> <legend>Information from Yelp </legend>";
					echo "Rating: <br/> <img border=0 src='".$yelp->getRating($businessRight)."'> (Based on ".$yelp->getReviewCount($businessRight)." reviews)<br/>";
					echo "<hr>";
					

					$reviews = $yelp->getReviews($businessRight,3);
					
					$i = 0;
					//echo "<fieldset> <legend> Reviews </legend>";
					echo "Reviews: <br/>";
					foreach($reviews as $review)
					{
						echo "Review ".$i.": ".$review[0]."<a target='_blank' href=\"".$review[1]."\">Read More..</a><br/>";
						$i++;
					}
					echo "<hr>";
					
					echo "Read more from this place at <a target='_blank' href=\"".$yelp->getUrl($businessRight)."\">Yelp</a><br/>";
					echo "<hr>";
					echo $yelp->printYelpLogo();
					echo "</fieldset>";
					
				}
			}//If not we throw the default error from the Yelp Object
			else
			{
				echo $YelpObject->message->text;
			}
		}
	}
	echo $html->link("Add to my route",array("controller"=>"posts","action"=>"addtoroute",$post["Post"]["id"]));

?>